<html>
<head>
<title>getcwd</title>
<body bgcolor=#ffffff>
<h2 align=center>getcwd</h2>
<h4 align=center>OS/161 Reference Manual</h4>

<h3>Name</h3>
getcwd - get name of current working directory

<h3>Library</h3>
Standard C Library (libc, -lc)

<h3>Synopsis</h3>
#include &lt;unistd.h&gt;<br>
<br>
char *<br>
getcwd(char *<em>buf</em>, size_t <em>buflen</em>);

<h3>Description</h3>

The name of the current directory is computed and stored in
<em>buf</em>, an area of size <em>buflen</em>. The resulting string is
0-terminated.
<p>

This call is a wrapper (for Unix compatibility) around the system call
<A HREF=../syscall/__getcwd.html>__getcwd</A>.
<p>

Note, however, that the BSD extension whereby space is allocated with
<A HREF=malloc.html>malloc</A> if <em>buf</em> is NULL is not supported.

<h3>Return Values</h3>
On success, getcwd returns <em>buf</em>.
On error, NULL is returned, and <A HREF=errno.html>errno</A>
is set according to the error encountered.

<h3>Errors</h3>

The following error codes should be returned under the conditions
given. Other error codes may be returned for other errors not
mentioned here.

<blockquote><table width=90%>
<td width=10%>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>ENOENT</td>	<td>A component of the pathname no longer exists.</td></tr>
<tr><td>EIO</td>		<td>A hard I/O error occurred.</td></tr>
<tr><td>EFAULT</td>		<td><em>buf</em> points to an invalid address.</td></tr>
</table></blockquote>

</body>
</html>
